import 'package:fluent_ui/fluent_ui.dart';
import 'package:provider/provider.dart';

import '../view_type.dart';
import 'school_daily_schedule_view_edit.dart';
import 'school_daily_schedule_view_list.dart';
import 'school_daily_schedule_view_model.dart';

///学校作息:视图入口
class SchoolDailyScheduleViewMain extends StatefulWidget {
  final ViewType type;
  final String? schoolId, id;

  const SchoolDailyScheduleViewMain(
      {super.key, required this.type, this.schoolId, this.id});

  @override
  State<SchoolDailyScheduleViewMain> createState() =>
      _SchoolDailyScheduleViewMainState();
}

class _SchoolDailyScheduleViewMainState
    extends State<SchoolDailyScheduleViewMain> {
  @override
  Widget build(BuildContext context) => ChangeNotifierProvider(
        create: (_) => SchoolDailyScheduleViewModel(),
        builder: (_, __) {
          if (widget.type == ViewType.edit) {
            return SchoolDailyScheduleViewEdit(
              schoolId: widget.schoolId ?? '',
              id: widget.id,
            );
          }
          return SchoolDailyScheduleViewList(schoolId: widget.schoolId ?? '');
        },
      );
}
